package com.yanqu.road.dao.impl.log;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.db.DbParameter;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.cricket.court.log.LogCricketCourtRoundRank;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LogCricketCourtRoundRankDaoImpl extends TempDao {

    public boolean addLogCricketCourtRoundRankList(List<LogCricketCourtRoundRank> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getCrossDb());
        String sql = "INSERT INTO t_c_log_cricket_court_round_rank(round,serverId,userId,courtId,groupId,score,param,rank,changeType,addTime) VALUES(?,?,?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (LogCricketCourtRoundRank data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.INTEGER, data.getRound()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getServerId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getCourtId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getGroupId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getScore()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getParam()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRank()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getChangeType()));
            para.put(i++, new DbParameter(Types.DATE, data.getAddTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

}
